Skip to content

fix: allow omitted task push config id - #1092

Open
hutiefang76 wants to merge 3 commits into
a2aproject:mainfrom
hutiefang76:codex/a2a-java-1081-optional-push-config-id
Open

fix: allow omitted task push config id#1092
hutiefang76 wants to merge 3 commits into
a2aproject:mainfrom
hutiefang76:codex/a2a-java-1081-optional-push-config-id

Conversation

@hutiefang76

Copy link
Copy Markdown

Description

Allow TaskPushNotificationConfig to omit its id when a client creates a push notification configuration, matching the A2A specification. The in-memory store now assigns the task ID when the supplied ID is null or empty, preserving its existing defaulting behavior.

Tests

  • mvn -pl spec,server-common -am -Dtest=TaskPushNotificationConfigTest,InMemoryPushNotificationConfigStoreTest -Dsurefire.failIfNoSpecifiedTests=false test

    • TaskPushNotificationConfigTest: 1 passed
    • InMemoryPushNotificationConfigStoreTest: 33 passed
  • Follow the CONTRIBUTING guide

  • Use a conventional commit title

  • Tests pass

  • README changes are not needed for this API-contract correction

Fixes #1081 🦕

@kabir kabir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hutiefang76 - thank you for the PR 👍

I found a few small issues in the code, but we also need to take JpaDatabasePushNotificationConfigStore into account and make some changes, and test this inline with what you have done here. JpaPushNotificationConfigStoreTest might be the right place.

Also GetTaskPushNotificationConfigParams asserts id non-null despite its Javadoc calling it optional. Might as well fix this since it is related.

public void testSetInfoWithoutConfigId() {
String taskId = "task1";
TaskPushNotificationConfig initialConfig = TaskPushNotificationConfig.builder()
.id("") // No ID set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a new test rather than changing this existing one.

Removing .id("") repurposes this test from the empty-string path to the null path rather than covering both.
The empty-string case is the one production actually hits — the mapper doesn't apply emptyToNull to id, so at runtime a missing id arrives as "", never null.
Recommend keeping the "" case here and adding a separate null-id test (or parameterizing over both), so the load-bearing branch stays asserted.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous comment should still be addressed.

assertEquals(taskId, configResult.configs().get(0).id());

TaskPushNotificationConfig updatedConfig = TaskPushNotificationConfig.builder()
.id("") // No ID set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a new test rather than changing this existing one.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous comment should still be addressed.

public TaskPushNotificationConfig setInfo(TaskPushNotificationConfig notificationConfig) {
String taskId = Assert.checkNotNullParam("taskId", notificationConfig.taskId());
TaskPushNotificationConfig.Builder builder = TaskPushNotificationConfig.builder(notificationConfig);
if (notificationConfig.id().isEmpty()) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a comment about this code, but JpaDatabasePushNotificationConfigStore has the same latent NPE, and needs fixing too.

@hutiefang76

Copy link
Copy Markdown
Author

Updated in 5bd4916.

  • JpaDatabasePushNotificationConfigStore now normalizes a null or empty config ID to the task ID, with a Quarkus/JPA regression test.
  • GetTaskPushNotificationConfigParams now permits an omitted ID through both its constructor and builder, consistent with its Javadoc. The request handler resolves an omitted ID to the task ID, matching creation and v0.3 compatibility behavior.
  • Added focused model and request-handler coverage.

Verified on JDK 17 with:
mvn -pl spec,server-common,extras/push-notification-config-store-database-jpa -am -Dtest=GetTaskPushNotificationConfigParamsTest,DefaultRequestHandlerTest,JpaPushNotificationConfigStoreTest -Dsurefire.failIfNoSpecifiedTests=false test

Result: 2 spec tests, 23 request-handler tests, and 16 JPA-store tests passed (one pre-existing disabled test).`

public void testSetInfoWithoutConfigId() {
String taskId = "task1";
TaskPushNotificationConfig initialConfig = TaskPushNotificationConfig.builder()
.id("") // No ID set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous comment should still be addressed.

assertEquals(taskId, configResult.configs().get(0).id());

TaskPushNotificationConfig updatedConfig = TaskPushNotificationConfig.builder()
.id("") // No ID set

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous comment should still be addressed.

@hutiefang76

Copy link
Copy Markdown
Author

Addressed in dab6633.

  • Restored the existing empty-id coverage with .id(""), so it continues to test the exact value emitted by the mapper.
  • Added a separate null-id regression test; it verifies the store derives the config id from the task id when the id is absent.
  • The equivalent JPA null/empty normalization is already included in 5bd4916.

Validated with GetTaskPushNotificationConfigParamsTest, DefaultRequestHandlerTest, InMemoryPushNotificationConfigStoreTest, and JpaPushNotificationConfigStoreTest (75 tests, 0 failures/errors).`

@kabir

kabir commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Sorry @hutiefang76 we're doing a lot of merging today, and there is now a conflict :-)

@hutiefang76
hutiefang76 force-pushed the codex/a2a-java-1081-optional-push-config-id branch from dab6633 to e4a3d37 Compare August 26, 2026 15:34
@hutiefang76

Copy link
Copy Markdown
Author

Rebased onto current main to resolve the merge conflict (latest head: e4a3d37). The resolution preserves upstream tenant validation while retaining the optional config-id contract and its empty-id/null-id coverage.\n\nValidated after the rebase with the focused spec, request-handler, in-memory-store, and JPA-store suites: 84 tests, 0 failures/errors; git diff --check also passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TaskPushNotificationConfig.id is enforced as required, contradicting the spec where id is optional on create

2 participants